from models.models import RoleAccessLink
from service.BaseService import BaseService
from config import settings
from sqlmodel import Session, select
from typing import Optional

class RoleAccessService(BaseService[RoleAccessLink]):
    def __init__(self):
        super().__init__(RoleAccessLink)

    def get_access_by_role(self, role_id: int):

        statment = select(RoleAccessLink).where(RoleAccessLink.role_id == role_id)
        return self.session.exec(statment).all()

    def create_role_access(self,user_id: str, access_id: str, role_id: str):
        role_main_access_link = RoleAccessLink(role_id=role_id, access_id=access_id, update_by = user_id, create_by = user_id)
        return self.create(role_main_access_link)



